﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class CoverScene : MonoBehaviour {
    public GameObject startTextGO;
    float timePassed = 0;
    float timeNeed = 1.0f;
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
        startTextBlinkUpdate(Time.deltaTime);
        inputUpdate();
	}

    void startTextBlinkUpdate(float detlaTime) {
        float a = 1.0f;
        timePassed += detlaTime;
        if (timePassed >= timeNeed){
            timePassed = 0;
        }
        if (timePassed < timeNeed / 2){
            float srcA = 1.0f;
            float dstA = .5f;
            float tn = timeNeed / 2;
            a = srcA + (dstA - srcA) * (timePassed / tn);
        }else{
            float srcA = .5f;
            float dstA = 1.0f;
            float tn = timeNeed / 2;
            float tp = timePassed - timeNeed / 2;
            a = srcA + (dstA - srcA) * (tp / tn);
        }
        startTextGO.GetComponent<Text>().color = new Color(255.0f, 255.0f, 255.0f, a);
    }
    void inputUpdate() {
        if (Input.GetMouseButtonUp(0)) {
            SceneManager.LoadScene("GameSceneNetwork");
        }
    }
}
